<?php
	$db = new mysqli('127.0.0.1', 'root', '', 'pollingasisten');
	if ($db->connect_errno) {
		die('Sorry, We have some problems.');
	}

function callUpdateAsisten($nim1,$nim2, $nama){
global $db;
if (!$db->query("CALL SpUpdateAsisten('{$nim1}','{$nim2}', '{$nama}')")) {
    	echo "CALL failed: (" . $db->errno . ") " . $db->error;
}

if (!($res = $db->query("SELECT NIM, nama FROM asisten"))) {
    	echo "SELECT failed: (" . $db->errno . ") " . $db->error;
}

var_dump($res->fetch_assoc());
}

	function callUpdateMatkul(){
	global $db;
	if (!$db->query("CALL SpUpdateMatkul('kode', 'kd_jurusan', 'namaMatkul')")) {
    	echo "CALL failed: (" . $db->errno . ") " . $db->error;
	}

	if (!($res = $db->query("SELECT kode, kd_jurusan, nama FROM matakuliah"))) {
    	echo "SELECT failed: (" . $db->errno . ") " . $db->error;
	}

	var_dump($res->fetch_assoc());
	}
	
	function callUpdateJadwal(){
	global $db;
	if (!$db->query("CALL SpUpdateJadwal('kode', 'kd_matkul', 'lab', 'hari','sesi')")) {
    	echo "CALL failed: (" . $db->errno . ") " . $db->error;
	}

	if (!($res = $db->query("SELECT kode, kd_matkul, lab, hari, sesi FROM jadwal"))) {
    	echo "SELECT failed: (" . $db->errno . ") " . $db->error;
	}

	var_dump($res->fetch_assoc());
	}

	function callUpdateJadwalAsisten(){
	global $db;
	if (!$db->query("CALL SpUpdateJadwalAsisten('NIM', 'kd_jadwal')")) {
    	echo "CALL failed: (" . $db->errno . ") " . $db->error;
	}

	if (!($res = $db->query("SELECT NIM, kd_jadwal FROM jadwalasisten"))) {
    	echo "SELECT failed: (" . $db->errno . ") " . $db->error;
	}

	var_dump($res->fetch_assoc());
	}

	callUpdateAsisten('11.11.5654','11.11.5655','Riana');

?>